﻿using Mirror;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MrPP.SampleGame { 
    public class Ball : NetworkBehaviour
    {
        public float speed = 3;
        [SerializeField]
        private Rigidbody _rigid;
        private float lifetime_ = 0.0f;

        public void Start() {
           // this.transform.SetParent(TargetPoint.Instance.transform);
        }
        public override void OnStartServer()
        {
            base.OnStartServer();
           
            _rigid.isKinematic = false;
            _rigid.velocity = transform.forward * speed;
           
        }

        [ServerCallback]
        
        // Update is called once per frame
        void Update()
        {
            lifetime_ += Time.deltaTime;
            if (lifetime_ > 20f) {
                NetworkServer.Destroy(this.gameObject);
            }
        }
    }
}